<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .item{
            width: 100px;
            height: 100px;
            border: 1px solid;
        }
    </style>
</head>
<body>
    <div id="wrap">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>
</body>
<script>
    window.onload=function () {
        //query系列是静态的   getxxx是动态的
        var warp = document.querySelector("#wrap");
        // var items = document.querySelectorAll("#wrap .item");
        var items = warp.getElementsByClassName("item");
        //改变dom结构 重绘重排
        warp.innerHTML += "<div class='item'></div>"

        // items = document.querySelectorAll("#wrap .item");
        for(var i=0;i<items.length;i++){
            items[i].style.background = "pink"
        }
    }
</script>
</html>